﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Fabrikator;
using FabrikatorDB;

namespace Fabrikatorum.Fabrikator.Sayfa
{
    public partial class Bonolariniz : System.Web.UI.Page
    {
        public string talimatsayisi { get; set; }
        public string satilanbono { get; set; }
        public string dolmusbono { get; set; }
        public string satinalinanbono { get; set; }
        public decimal piyasadegerne { get; set; }
        public string bonocikarmatutar { get; set; }
        public string bonocikarmaadet { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["uye"] != null)
            {

                using (FabriDataContext db = new FabriDataContext())
                {
                    Uye girisyapan = (Uye)Session["uye"];
                    Bono sinif = new Bono();
                    decimal[] limitler = new decimal[] { 0, 0 };
                    limitler = sinif.BonoYeterlilikKontrol(girisyapan.UyeNo);
                    bonocikarmaadet = (20-limitler[0]).ToString();
                    bonocikarmatutar = string.Format("{0:n}", limitler[1]);
                    talimatsayisi = (from tlmt in db.BonoTalimats where tlmt.UyeNo == girisyapan.UyeNo && tlmt.Durum == 1 select tlmt).Count().ToString();
                    satilanbono = (from tlmt in db.BonoTalimats where tlmt.UyeNo == girisyapan.UyeNo && tlmt.Durum == 2 select tlmt).Count().ToString();
                    dolmusbono = (from tlmt in db.BonoTalimats where tlmt.UyeNo == girisyapan.UyeNo && tlmt.Durum == 3 select tlmt).Count().ToString();
                    satinalinanbono = (from tlmt in db.BonoTalimats where tlmt.UyeNoAlan == girisyapan.UyeNo && tlmt.Durum == 2 select tlmt).Count().ToString();
                }
            }
            else
            {
                Response.Redirect("~/Fabrikator/Sayfa/GirisUyari.html");
            }

        }
    }
}